Conditions | 1 |
Paths | 1 |
Total Lines | 69 |
Code Lines | 39 |
Lines | 0 |
Ratio | 0 % |
Changes | 2 | ||
Bugs | 0 | Features | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | module.exports = function( grunt ) { |
||
2 | // Project configuration. |
||
3 | grunt.initConfig( { |
||
4 | // Package |
||
5 | pkg: grunt.file.readJSON( 'package.json' ), |
||
6 | |||
7 | // JSHint |
||
8 | jshint: { |
||
9 | all: [ 'Gruntfile.js', 'composer.json', 'package.json' ] |
||
10 | }, |
||
11 | |||
12 | // PHP Code Sniffer |
||
13 | phpcs: { |
||
14 | application: { |
||
15 | src: [ |
||
16 | '**/*.php', |
||
17 | '!node_modules/**', |
||
18 | '!vendor/**', |
||
19 | '!wp-content/**', |
||
20 | '!wordpress/**' |
||
21 | ] |
||
22 | }, |
||
23 | options: { |
||
24 | bin: 'vendor/bin/phpcs', |
||
25 | standard: 'phpcs.ruleset.xml', |
||
26 | showSniffCodes: true |
||
27 | } |
||
28 | }, |
||
29 | |||
30 | // PHPLint |
||
31 | phplint: { |
||
32 | options: { |
||
33 | phpArgs: { |
||
34 | '-lf': null |
||
35 | } |
||
36 | }, |
||
37 | all: [ 'src/**/*.php' ] |
||
38 | }, |
||
39 | |||
40 | // PHP Mess Detector |
||
41 | phpmd: { |
||
42 | application: { |
||
43 | dir: 'src' |
||
44 | }, |
||
45 | options: { |
||
46 | bin: 'vendor/bin/phpmd', |
||
47 | exclude: 'node_modules', |
||
48 | reportFormat: 'xml', |
||
49 | rulesets: 'phpmd.ruleset.xml' |
||
50 | } |
||
51 | }, |
||
52 | |||
53 | // PHPUnit |
||
54 | phpunit: { |
||
55 | options: { |
||
56 | bin: 'vendor/bin/phpunit' |
||
57 | }, |
||
58 | application: {}, |
||
59 | } |
||
60 | } ); |
||
61 | |||
62 | grunt.loadNpmTasks( 'grunt-contrib-jshint' ); |
||
63 | grunt.loadNpmTasks( 'grunt-phpcs' ); |
||
64 | grunt.loadNpmTasks( 'grunt-phplint' ); |
||
65 | grunt.loadNpmTasks( 'grunt-phpmd' ); |
||
66 | |||
67 | // Default task(s). |
||
68 | grunt.registerTask( 'default', [ 'jshint', 'phplint', 'phpmd', 'phpcs' ] ); |
||
69 | }; |
||
70 |